<template>
  <div>
    <el-table
      border
      stripe
      :data="results"
      :height="height"
      @row-dblclick="detail"
    >
      <el-table-column
        label="编号"
        width="80"
        align="center"
      >
        <template v-slot="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column
        label="日期"
        prop="gdate"
        align="center"
      />
      <el-table-column
        label="所在地块"
        prop="field"
        align="center"
      >
        <template #default="scope">
          {{ getAttr(scope.row.plant.field_id,'id',fields) }}
        </template>
      </el-table-column>
      <el-table-column
        label="作物"
        prop="crop"
        align="center"
      >
        <template #default="scope">
          {{ getAttr(scope.row.plant.crop_id,'id',crops) }}
        </template>
      </el-table-column>
      <el-table-column
        label="生育期"
        prop="growth_stage"
        align="center"
      />
      <el-table-column
        label="kc"
        prop="kc"
        align="center"
      />
      <el-table-column
        label="灌溉下限(%)"
        prop="wc_min"
        align="center"
      />
      <el-table-column
        label="灌溉上限(%)"
        prop="wc_max"
        align="center"
      />
      <el-table-column
        label="湿润层深度(cm)"
        prop="soil_depth"
        align="center"
      />
      <!-- <el-table-column
        label="预测高度"
        prop="height_prog"
        align="center"
      />
      <el-table-column
        label="实际高度"
        prop="height_real"
        align="center"
      />
      <el-table-column
        label="预测根深"
        prop="depth_prog"
        align="center"
      />
      <el-table-column
        label="实际根深"
        prop="depth_real"
        align="center"
      /> -->
      <!-- <el-table-column
        label="ETc"
        prop="water_consum"
        align="center"
      /> -->
      <el-table-column
        label="土壤含水率(%)"
        prop="water_content"
        align="center"
      />
      <el-table-column
        label="ETc(%)"
        prop="water_consum"
        align="center"
      />
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-link type="primary" icon="el-icon-edit" @click="edit(scope.row)">修改</el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>

</template>

<script>
import { mapGetters } from 'vuex'
import { getAttr } from '@/utils'
export default {
  props: {
    results: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      height: 'calc(100vh - 224px)'
    }
  },
  computed: {
    ...mapGetters(['crops', 'fields'])
  },
  methods: {
    detail(row) {
      console.log(row)
    },
    edit(row) {
      this.$emit('edit', row)
    },
    getAttr(value, name, datas) {
      return getAttr(value, name, datas)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>

